# Docker 镜像构建
FROM maven:3.8.1-jdk-8-slim as builder

# Copy local code to the container image.
WORKDIR /app
COPY tourism_backend/pom.xml .
COPY tourism_backend/src ./src

# Build a release artifact.
RUN mvn package -DskipTests

# 使用轻量级JDK镜像运行
FROM openjdk:8-jre-slim

WORKDIR /app

# 复制构建好的jar文件
COPY --from=builder /app/target/springboot-init-0.0.1-SNAPSHOT.jar /app/app.jar

# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 暴露端口
EXPOSE 8887

# 启动命令
ENTRYPOINT ["java","-jar","/app/app.jar","--spring.profiles.active=prod"]